const { resolve } = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin');

const entry = {
  main: resolve(__dirname, 'src', 'index.js'),
  second: resolve(__dirname, 'src', 'second.js'),
}

const output = {
  path: resolve(__dirname, 'build'),
  filename: '[name].js',
  clean: true,
}

const loaders = [
  {
    test: /\.js$/,
    use: {
      loader: 'imports-loader',
      options: {
        wrapper: 'window'
      }
    },
  }
]

const plugins = [
  new HtmlWebpackPlugin(),
]

module.exports = {
  entry, 
  output,
  plugins,
  mode: 'development',
  devtool: false,
  devServer: {
    open: true
  },
  module: {
    rules: loaders
  }
}